import instance from '@/utils/request'

// 获取轮播图列表
export function getBanners(params) {
    return instance.request({
        method: 'get',
        url: '/api/banners',
        params
    })
}

// 获取轮播图详情
export function getBannerDetail(id) {
    return instance.request({
        method: 'get',
        url: `/api/banners/${id}`
    })
}

// 创建轮播图
export function createBanner(data) {
    return instance.request({
        method: 'post',
        url: '/api/banners',
        data
    })
}

// 更新轮播图
export function updateBanner(id, data) {
    return instance.request({
        method: 'put',
        url: `/api/banners/${id}`,
        data
    })
}

// 删除轮播图
export function deleteBanner(id) {
    return instance.request({
        method: 'delete',
        url: `/api/banners/${id}`
    })
}

// 切换轮播图状态
export function toggleBannerStatus(id) {
    return instance.request({
        method: 'patch',
        url: `/api/banners/${id}/toggle-status`
    })
}

// 批量更新轮播图排序
export function batchUpdateBannerOrders(data) {
    return instance.request({
        method: 'post',
        url: '/api/banners/batch-update-orders',
        data
    })
}

// 批量删除轮播图
export function batchDeleteBanners(data) {
    return instance.request({
        method: 'post',
        url: '/api/banners/batch-delete',
        data
    })
}

// 获取活跃轮播图
export function getActiveBanners() {
    return instance.request({
        method: 'get',
        url: '/api/banners/active'
    })
}

// 获取轮播图统计
export function getBannerStats() {
    return instance.request({
        method: 'get',
        url: '/api/banners/stats'
    })
}